<?php
// +----------------------------------------------------------------------
// | KITEGO-Admin「开箱即用」「人人全栈」
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2024 https://www.kitego.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed KITEGO并不是自由软件，未经许可不能去掉KITEGO相关版权
// +----------------------------------------------------------------------
// | Author: KITEGO Team <bd@kitego.cn>
// +----------------------------------------------------------------------

namespace kitego\enums;

use ReflectionClass;

final class PlatformEnum
{
    private function __construct() {} // 防止实例化

    const IOS = 1; // 苹果
    const ANDROID = 2; // 安卓
    const HARMONY = 3; // 鸿蒙
    const H5 = 4; // 手机网页
    const PC = 5; // 电脑网页
    const OA = 6; // 微信公众号
    const MP_WEIXIN = 7; // 微信小程序
    const MP_ALIPAY = 8; // 支付宝小程序

    public static function all(): array
    {
        $reflection = new ReflectionClass(__CLASS__);

        return $reflection->getConstants();
    }

    public static function key($value): int|string
    {
        $keyName = array_search($value, self::all());

        return $keyName !== false ? $keyName : '';
    }

    public static function isApp($value): bool
    {
        return in_array($value, [self::IOS, self::ANDROID, self::HARMONY]);
    }
}